package com.oa.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@WebListener
public class ContextLoaderListener implements ServletContextListener {

	@Override
	public void contextInitialized(ServletContextEvent event) {
		System.out.println("===服务器启动====");
		String springFile = event.getServletContext().getInitParameter("contextConfigLocation");
		ApplicationContext ctx = new ClassPathXmlApplicationContext(springFile);
		event.getServletContext().setAttribute("ctx", ctx);
	}
	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		System.out.println("====服务器停止======");
	}

	

}
